//
//  WYCommissionController.m
//  CirclePush
//
//  Created by admin on 2018/4/19.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYCommissionController.h"
#import "WYCommissionCell.h"
#import "WYExtractModel.h"
@interface WYCommissionController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) IBOutlet UIView *mainView;
@property (strong, nonatomic) IBOutlet UITableView *alreadyTableView;
@property (strong, nonatomic) IBOutlet UITableView *connecTableView;
@property (strong, nonatomic) IBOutlet UITableView *compleTableView;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *topHeight;

@property (strong, nonatomic) IBOutlet UILabel *priceLabel;

@property (nonatomic,strong)NSMutableArray *dataArray;

@end

@implementation WYCommissionController
-(NSMutableArray *)dataArray
{
    if (!_dataArray) {
        _dataArray =[[NSMutableArray alloc]init];
    }
    return _dataArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    [self loadData];
}

-(void)loadData
{
    WEAKSELF
    [WYHttpServer getExtractListWithState:@"1" WithPageNum:@"1" WithPageSize:@"10" SucessBlock:^(BOOL success, id response, NSString *errorMessage) {
        if (success) {
            NSArray *array = [WYExtractModel getExtractModelFromJson:response[@"result"]];
            if (array.count) {
                [weakSelf.dataArray addObject:array];
            }
        }
        [weakSelf.alreadyTableView reloadData];
        
        
    }];
    
    
}



-(void)setupUI
{
    [self initTopBarWithTitle:@"我的提成"];
    [self addLeftButton:[UIImage imageNamed:@"return"] width:0 height:0];
    self.alreadyTableView.delegate=self;
    self.alreadyTableView.dataSource=self;
    self.alreadyTableView.tableFooterView =[[UIView alloc]init];
    if (kDevice_Is_iPhoneX) {
        self.topHeight.constant = 85;
    }
    self.topBar.backgroundColor = [UIColor hexStringToColor:@"#007AFF" alpha:1.0];
    [self.leftButton setTintColor:[UIColor whiteColor]];
    self.viewBottomLine.backgroundColor = [UIColor hexStringToColor:@"#007AFF" alpha:1.0];;
    self.titleLabel.textColor = [UIColor whiteColor];
    
    self.priceLabel.text = [NSString stringWithFormat:@"%.2f",self.price.floatValue];
    
//    self.connecTableView.delegate = self;
//    self.connecTableView.dataSource = self;
//
//    self.compleTableView.delegate = self;
//    self.compleTableView.dataSource = self;
//
//    self.mainView.width = kScreenWidth*3;
//    self.mainView.height = kScreenHeight;
//    [self.scrollView addSubview:self.mainView];
 //   self.scrollView.contentSize = self.mainView.size;
    
//    [self.connecTableView registerNib:[UINib nibWithNibName:@"WYCommissionCell" bundle:nil] forCellReuseIdentifier:@"WYCommissionCell"];
//
//     [self.compleTableView registerNib:[UINib nibWithNibName:@"WYCommissionCell" bundle:nil] forCellReuseIdentifier:@"WYCommissionCell"];
    
     [self.alreadyTableView registerNib:[UINib nibWithNibName:@"WYCommissionCell" bundle:nil] forCellReuseIdentifier:@"WYCommissionCell"];
    
    
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.dataArray[section] count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WYCommissionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WYCommissionCell" forIndexPath:indexPath];
    
    WYExtractModel *model = self.dataArray[indexPath.section][indexPath.row];
    [cell setModel:model];
    
    
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 66;
}

@end
